using Mapster;
using Vin.Extension.Framework.Base;
using Vin.Extension.Framework.Geo.Dto.Entities;
using Vin.Extension.Framework.Geo.Repository;
using Vin.Extension.Framework.Geo.ServiceInterface;
using Vin.Tool.Attributes;

namespace Vin.Extension.Framework.Geo.Service;

public class SysGeoService : VinFrameworkBaseService, ISysGeoService
{
    public const string SysGeoCacheKey = "System:Geo:List";

    [Inject] private readonly SysGeoRepository _sysGeoRepository = null!;

    public async Task<List<SysGeoDto>> ListAsync(long pid = 0)
    {
        return (await _sysGeoRepository.GetListAsync(m => m.Pid == pid)).Adapt<List<SysGeoDto>>();
    }

    [Obsolete()]
    public async Task<List<SysGeoDto>> ListAllCacheAsync()
    {
        return new List<SysGeoDto>();
        // var result = await GetRedisCache().GetCacheAsync<List<SysGeoDto>>(SysGeoCacheKey);
        // if (result != null) return result;
        //
        // var list = await _sysGeoRepository.GetListAsync();
        // result = list.Adapt<List<SysGeoDto>>();
        // await GetRedisCache().SetCacheAsync(SysGeoCacheKey, result);
        // return result;
    }

    public async Task<List<SysGeoDto>> ListByDeepAsync(long deep = 0)
    {
        return (await _sysGeoRepository.GetListAsync(m => m.Deep == deep)).Adapt<List<SysGeoDto>>();
    }
}